package com.xywl.escort.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xywl.escort.R;
import com.xywl.escort.bean.BandCardListResp;

import java.util.List;

public class BandCardDialogListAdapter extends BaseQuickAdapter<BandCardListResp.DataBean.ListBean, BaseViewHolder> {
    private BandCardListResp.DataBean.ListBean mBandBean;

    public BandCardDialogListAdapter(int layoutResId, @Nullable List<BandCardListResp.DataBean.ListBean> data, BandCardListResp.DataBean.ListBean bandBean) {
        super(layoutResId, data);
        mBandBean = bandBean;
    }

    @Override
    protected void convert(BaseViewHolder helper, BandCardListResp.DataBean.ListBean item) {
        String bankName = item.bankName;
        String bankCardNo = item.bankCardNo;
        if (bankCardNo.length() > 4) {
            bankName = bankName + " (" + bankCardNo.substring(bankCardNo.length() - 4, bankCardNo.length()) + ")";
        } else {
            bankName = bankName + " (" + bankCardNo + ")";
        }
        helper.setText(R.id.text_band_name, bankName);
        ImageView imageCheck = helper.getView(R.id.image_check);
        if (null != mBandBean && mBandBean.id.equals(item.id)) {
            imageCheck.setImageResource(R.mipmap.bazaar_choose);
        } else {
            imageCheck.setImageResource(R.mipmap.bazaar_not_to_choose);
        }
        helper.addOnClickListener(R.id.text_band_name);
    }
}
